require("../config/api.js"), module.exports = {
    request: function(e) {
        var t = function(t) {
            return (t = t.toString())[1] ? t : "0".concat(t);
        };
        var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, o = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "GET", i = arguments.length > 3 && void 0 !== arguments[3] && arguments[3];
        return i || wx.showLoading({
            title: "加载中",
            mask: !0
        }), new Promise(function(n, a) {
            wx.request({
                url: e,
                data: t,
                method: o,
                header: {
                    "Content-Type": "application/json",
                    "X-Nideshop-Token": wx.getStorageSync("token")
                },
                success: function(e) {
                    200 == e.statusCode ? n(e.data) : a(e.errMsg), i || wx.hideLoading();
                },
                fail: function(e) {
                    a(e), console.log("failed"), wx.hideLoading(), wx.showToast({
                        title: "网络出问题了",
                        image: "/static/images/icon_error.png",
                        duration: 3e3
                    });
                }
            });
        });
    },
    buttonClicked: function(e) {
        e.setData({
            buttonClicked: !0
        }), setTimeout(function() {
            e.setData({
                buttonClicked: !1
            });
        }, 1e3);
    }
};
const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}

module.exports = {
  formatTime: formatTime
}

module.exports = {
    formatTime: function(e) {
        var n = e.getFullYear(), o = e.getMonth() + 1, u = e.getDate(), c = e.getHours(), a = e.getMinutes(), i = e.getSeconds();
        return "".concat([ n, o, u ].map(t).join("/"), " ").concat([ c, a, i ].map(t).join(":"));
    }
}, module.exports = {
    buttonClicked: function(t) {
        t.setData({
            buttonClicked: !0
        }), setTimeout(function() {
            t.setData({
                buttonClicked: !1
            });
        }, 1e3);
    }
};